const path = require('path');
const { defineConfig } = require("@vue/cli-service");

module.exports = defineConfig({
    transpileDependencies: true,
    productionSourceMap: false,
    lintOnSave: false,
    publicPath: "./",
    outputDir: "./dist",
    assetsDir: "",
    devServer: {
        port: 8080,
        open: true,
        hot: true,
        client: {
            overlay: {
                warnings: true,
                errors: true,
            },
        },

        proxy: {
            "/online-demo": {
                target: process.env.VUE_APP_BASE_API,
                changeOrigin: true,
                pathRewrite: {
                    "^/online-demo": "/online-demo", //打包
                    "^/online-demo": "/online-demo", //本地好用，publicPath是./
                },
                cookiePathRewrite: {
                    //重写cookie路径
                    // "/online-demo": "/",
                },
            },
        },
    },
    configureWebpack: {
        resolve: {
            alias: {
                '@': path.resolve(__dirname, 'src') 
            }
        }
    },
    chainWebpack: config => {
        config.module
        .rule('markdown')
        .test(/\.md$/)
        .use('vue-loader')
        .loader('vue-loader')
        .end()
        .use('vue-markdown-loader')
        .loader(path.resolve(__dirname, 'loaders/markdown-loader.js'));
    }
});

